/**
 *	VisualGroup JavaScript prototype Classes, version 0.1
 *  (c) 2008 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/
using("Vsg.FlashRemoteHandler.Submit");
using("Vsg.FlashRemoteHandler.Load");

Vsg.PostCrossDomainProxy = Ext.extend(Ext.util.Observable,{
	
	constructor:function($config) {
		
		Ext.apply(this , $config);
		
		Vsg.PostCrossDomainProxy.superclass.constructor.call(this, $config);
		
	},
	
	doAction : function(action, $options){
        if(typeof action == 'string'){
			if (action == "load") {

				action = new Vsg.FlashRemoteHandler.Load(this.form , $options);
			}
			if (action == "submit") {
				action = new Vsg.FlashRemoteHandler.Submit(this.form , $options);
			}
        }
        if(this.form.fireEvent('beforeaction', this.form, action) !== false){
            this.form.beforeAction(action);
            action.run.defer(100, action);
        }
        return this;		
	},

	
	load:function($opt) {

        this.doAction('load', $opt);
        return this;
		
	},
	
	submit:function($opt) {
		
		var v = this.form.isValid();
		if(v){
	        this.doAction('submit', $opt);
        }
		return this;
	}

});